
module.exports = class extends think.Controller {
  // 构造方法
  constructor(ctx) {
    super(ctx);
  }
  async __before() {
    this.setCorsHeader();
    this.ws = 'ws';
  }
  indexAction() {
    return this.success('外部接口');
  }

  // 跨域设置
  setCorsHeader() {
    this.header('Access-Control-Allow-Origin', this.header('origin') || '*');
    this.header('Access-Control-Allow-Headers', 'x-requested-with');
    this.header('Access-Control-Request-Method', 'GET,POST,PUT,DELETE');
    this.header('Access-Control-Allow-Credentials', 'true');
  }
};
